@extends('layouts/app')

@section('content')
{{-- agent添加员工--}}
<div class="weui-pay append employee">

    <div class="site weui-cells_checkbox">
        <div class="weui-cell ">
            <div class="weui-cell__hd">
                <label for="name">姓名</label>
            </div>
            <div class="weui-cell__bd">
                <input class="weui-input" name="name" placeholder="">
            </div>
        </div>
    </div>

    <div class="site weui-cells_checkbox">
        <div class="weui-cell ">
            <div class="weui-cell__hd">
                <label for="name" >密码</label>
            </div>
            <div class="weui-cell__bd">
                <input class="weui-input" type="number" pattern="[0-9]*" name="password" placeholder="请输入数字!">
            </div>
        </div>
    </div>

    <div class="site weui-cells_checkbox">
        <div class="weui-cell ">
            <div class="weui-cell__hd">
                <label for="name">手机号</label>
            </div>
            <div class="weui-cell__bd">
                <input class="weui-input" type="number" pattern="[0-9]*" name="mobile" placeholder="18888888888">
            </div>
        </div>
    </div>
    <div class="site weui-cells_checkbox">
        <div class="weui-cell ">
            <div class="weui-cell__hd">
                <label for="name">职位</label>
            </div>
            <div class="weui-cell__bd">
                <select class="weui-select" name="role">
                    <option value="0">财务</option>
                    <option selected="" value="1">服务员</option>
                    <option value="2">经理</option>
                    <option value="3">前台</option>
                </select>
            </div>
            <div class="weui-cell__dd">
                <svg class="icon f40" aria-hidden="true">
                    <use xlink:href="#icon--34"></use>
                </svg>
            </div>
        </div>
    </div>
    <div class="demos-content-padded">
        <a href="javascript:;" class="weui-btn weui-btn_blue open-popup">确认</a>
    </div>
</div>

<script>
     {{--请求数据接口方法--}}
    var id  = getRequest().id;

    //点击事件声明
    $(".open-popup").click(function(){
        //声明变量
        var data= {};
        //用户参数
        data['shop_id'] =id;
         //名称参数
        data['name'] =$("input[name='name']").val();
         //密码参数
        data['password'] =$("input[name='password']").val();
        //手机号参数
        data['mobile'] =$("input[name='mobile']").val();
        //职位参数
        data['role'] =$("select[name='role']").val();
         //请求数据接口/api/clerk/add
        $.post("/api/clerk/add",data,function(res){
            console.log("res",res);
            //判断字符串,
             if(typeof res === 'string') {
             //字符串转换成对象
                 res =JSON.parse(res);
             }
            //返回值
            $.alert (res.info);
            if(res.code ===200){
             //返回刷新
                history.go(-1);
            }
        });
    });
</script>
@endsection
@extends('layouts/footer')
